package com.jmu.medicineknows.controller;

import com.jmu.medicineknows.dto.DrugPageDto;
import com.jmu.medicineknows.entity.DrugInfo;
import com.jmu.medicineknows.entity.Result;
import com.jmu.medicineknows.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: JieZi
 * @Date: 2023/7/12 09:11
 * @Description:
 **/
@RestController
@RequestMapping("/drug")
public class DrugController {

    @Autowired
    public DrugService drugService;
    @RequestMapping("/list")
    public Result drugList(@RequestBody DrugPageDto drugPageDto){
        return drugService.drugList(drugPageDto);
    }

    @RequestMapping("/update")
    public Result update(@RequestBody DrugInfo DrugInfo){
        return drugService.updateDrug(DrugInfo);
    }

    @RequestMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Long id){
        return drugService.delete(id);
    }

    @RequestMapping("/insert")
    public Result insert(@RequestBody DrugInfo drugInfo){
        return drugService.insert(drugInfo);
    }

    @RequestMapping("/upload")
    public Result upload(MultipartFile file){
        return drugService.upload(file);
    }
}